package com.bmob.lover.data.model.bean

import com.theone.common.ext.getTimeDistance
import com.bmob.lover.data.constant.AnniversaryConstant
import java.util.*

/**
 * @author The one
 * @date 2021-07-25 20:35
 * @describe 纪念日
 * @email 625805189@qq.com
 * @remark
 */
class Anniversary : BaseLoverBean() {

    var name: String? = null
        get() =
            if (type == AnniversaryConstant.TYPE_Reciprocal)
                "${field}还有"
            else
                field

    var date: BmobDate? = null

    // 类型 0 纪念日  1 倒数日
    var type: Int? = -1

    fun diffDay(): String {
        var diff = 0
        date?.getDate()?.let {
            diff = if (type == 0)
                getTimeDistance(Date(), it)
            else
                getTimeDistance(it, Date())
        }
        return diff.toString()
    }


}